import os
import random
import time
from multiprocessing import Process


def task(name):
    print(f'{name} is processing')
    time.sleep(random.randrange(1, 3))
    print(f'{name} is end')


def task2(name):
    for i in range(5):
        print(f'{name} is processing')
        time.sleep(random.randrange(1, 3))
        print(f'{name} is end')


if __name__ == '__main__':
    p = Process(target=task, args=('thread1',))
    p2 = Process(target=task2, args=('thread2',))
    p2.daemon = True
    p.start()
    p2.start()
    print(f'{os.getpid()} 进程结束')
